package com.wf.ew.storage.service.impl;

import com.wf.ew.common.JsonResult;
import com.wf.ew.common.PageResult;
import com.wf.ew.system.model.User;
import com.wf.ew.storage.biz.ProductStorageBiz;
import com.wf.ew.storage.model.ProductStorage;
import com.wf.ew.storage.service.ProductStorageService;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.List;

/**
 *
 * 数据服务层接口实现类
 * @author : Doman
 * @date : 2019-11-18 12:37:27
 * @version ：1.0
 */
@Service
public class ProductStorageServiceImpl implements ProductStorageService {

	@Autowired
	private ProductStorageBiz productStorageBiz;

	@Override
	public String list(PageResult<T> page, ProductStorage productStorage, User loginUser) {
		return productStorageBiz.list(page,productStorage,loginUser);
	}
	
	@Override
	public List<ProductStorage> list(ProductStorage productStorage, User loginUser) {
		return productStorageBiz.list(productStorage,loginUser);
	}

	@Override
	public ProductStorage getById(ProductStorage productStorage) {
		return productStorageBiz.getById(productStorage);
	}

	@Override
	public List<ProductStorage> ajaxProductStorageNum(ProductStorage productStorage, User loginUser) {
		return productStorageBiz.ajaxProductStorageNum(productStorage,loginUser);
	}

	@Transactional
	@Override
	public JsonResult add(ProductStorage productStorage, User loginUser) {
		if (productStorageBiz.add(productStorage, loginUser)) {
			return JsonResult.ok("添加成功");
		}
		return JsonResult.error("添加失败");
	}

	@Transactional
	@Override
	public JsonResult update(ProductStorage productStorage, User loginUser) {
		if (productStorageBiz.update(productStorage, loginUser)) {
			return JsonResult.ok("修改成功");
		}
		return JsonResult.error("修改失败");
	}

	@Transactional
	@Override
	public JsonResult delete(ProductStorage productStorage, User loginUser) {
		if (productStorageBiz.delete(productStorage, loginUser)) {
			return JsonResult.ok("删除成功");
		}
		return JsonResult.error("删除失败");
	}
}
